{include file="public/open_head" /}
<style>

</style>
<div class="ok-body">

  <div class="layui-fluid">
    <div class="layui-card">

      <div class="layui-card-body" style="padding: 15px;">
        <div class="layui-form">

          <div class="layui-form-item">
            <label class="layui-form-label">员工工号：</label>
            <div class="layui-input-block input-custom-width" style="width: 450px;display: flex;">
              <input type="text" id="userinfo"  value="" placeholder="请输入员工工号" lay-filter="userinfo" lay-verify="" lay-verType="tips" lay-reqText="请输入员工工号"  autocomplete="off"  class="layui-input">
              <button href="javascript:;" class="layui-btn layui-btn-normal" style="margin-left: 15px;" id="queryinfo">查询</button>
            </div>
          </div>

          {lv:Input  name="user_id" id="user_id"  verify=""  value=""  type="hidden"  place=""   /}

          <div class="layui-form-item">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-inline">
              <input type="text" id="username" value="" readonly placeholder="" lay-verify="required" lay-vertype="" lay-reqtext="请输入员工工号" autocomplete="off" class="layui-input name" style="width:450px;border: none;padding-left: 0px;">
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">手机号码：</label>
            <div class="layui-input-inline">
              <input type="text" id="userphone" value="" readonly placeholder="" lay-verify="required" lay-vertype="" lay-reqtext="请输入员工工号" autocomplete="off" class="layui-input name" style="width:450px;border: none;padding-left: 0px;">
            </div>
          </div>

          {:widget('forms/submit',array('add','立即提交',0))}

        </div>
      </div>
    </div>
  </div>


</div>




<script>
  layui.use(['element', 'form', 'jquery','upload','laydate','lucky'], function () {
    var element = layui.element;
    var table = layui.table;
    var form = layui.form;
    var $ = layui.jquery;
    var laydate = layui.laydate;
    var lucky=layui.lucky;

    form.render();

    $("#queryinfo").on('click',function (){
      let userinfo = $("#userinfo").val();
      if(userinfo.length <=0){
        layer.msg("请输入用户信息",{time:1500});return false;
      }
      $.ajax({
        url: "{:url('user/queryuserinfo')}",
        dataType: 'json',
        type:'post',
        timeout: 120000,
        beforeSend: function (input) {
          loading = layer.load(2, {
            shade: [0.2, '#000'] //0.2透明度的白色背景
          });
        },
        data:{userinfo: userinfo},
        success: function(drs){
          console.log(drs);
          layer.close(loading);
          if(drs.code == 0){
            layer.msg(drs.msg,{time:1500});return false;
          }
          else if(drs.code == 1){
            $("#user_id").val(drs.data.user_id);
            $("#username").val(drs.data.username);
            $("#userphone").val(drs.data.mobile);
            // form.render();
          }
        },
        error: function(xml, errstr, err) {
          layer.close(loading);
          layer.alert(errstr+'，获取数据失败！');
        }
      });
      console.log(userinfo);
    })

    /**
     * 提交表单数据
     */
    form.on('submit(add)', function (data) {
      console.log(data);
      // return false;
      lucky.FormSubmit("{:url('user/syncuser')}",data.field,"tableFilter",1);
      return false;
    });
  })
</script>


</body>
</html>
